﻿<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <form action="?" method="post">
                    <div class="widget-title">
                        <span class="icon"><i class="icon-th"></i></span>
                        <h5>广告列表</h5>
                    </div>
                    <div class="widget-content">
                        <a href="@Url.Action("Info")" class="btn btn-success">添加</a>
                    </div>
                    <div class="widget-content">
                        <table class="table table-bordered table-striped with-check">
                            <thead>
                                <tr>
                                    <th>编号
                                    </th>
                                    <th>文件名
                                    </th>
                                    <th>发布状态
                                    </th>
                                    <th>操作
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach (Advertisement item in ViewBag.PagList.DataList)
                                {
                                    <tr>
                                        <td>
                                            @item.Id
                                        </td>
                                        <td>
                                            @item.FileName
                                        </td>
                                        <td>
                                            @if (@item.IsRelease == "N")
                                            {
                                                <span class="label">待发布</span>
                                            }
                                            else
                                            {
                                                <span class="label label-success">已发布</span>
                                            }
                                        </td>
                                        <td style="text-align: center">
                                            <a class="btn btn-primary btn-mini" href="@Url.Action("Info", new { item.Id })">编辑</a>
                                            <input  type="button" value="删除" class="btn btn-danger btn-mini" onclick="DelAd(@item.Id)" />
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                        @Html.Partial("_Paging")
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //删除
    function DelAd(id) {
        if (confirm("确认删除？")) {
            $("#LoadingBox").show();
            $.post('@Url.Action("Delete")', "id=" + id, function () {
                $("#LoadingBox").hide();
                //刷新页面，页码不变
                $("form").submit();
            });
        }
    }
</script>
